<?php echo $this->render('header.phtml'); ?>
<?php	
	if (isset($this->errors)){
		$errors = $this->errors;
		if (key_exists('message', $errors))$message = $errors['message'] ;
		if (key_exists('username', $errors)) $username = $errors['username'] ;
		if (key_exists('username_null', $errors)) $username_null = $errors['username_null'];
		if (key_exists('password_null', $errors)) $password_null = $errors['password_null'];
	}
?>
<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery('#username').focus();
	});
</script>
<div class="clr"></div>
<div id="box-content">
		<?php
			$cities = $this->cities;
			$day = $this->day;
			$month = $this->month;
			$y = $this->year;
			$account = (object) $this->account;
			if (isset($this->errors)){
				$errors = $this->errors;
				if (key_exists("mobile_null", $errors)) $mobile_null = $errors['mobile_null'];
				if (key_exists("mobile_exist", $errors)) $mobile_exist = $errors['mobile_exist'];
				if (key_exists("mobile_incorrect", $errors)) $mobile_incorrect = $errors['mobile_incorrect'];
				if (key_exists("password_null", $errors)) $password_null = $errors['password_null'];
				if (key_exists("password_incorrect", $errors)) $password_incorrect = $errors['password_incorrect'];
				if (key_exists("password2_incorrect", $errors)) $password2_incorrect = $errors['password2_incorrect'];
				if (key_exists("city_null", $errors)) $city_null = $errors['city_null'];
				if (key_exists("fullname_null", $errors)) $fullname_null = $errors['fullname_null'];
				if (key_exists("email_null", $errors)) $email_null = $errors['email_null'];
				if (key_exists("email_incorrect", $errors)) $email_incorrect = $errors['email_incorrect'];
				if (key_exists("captcha_null", $errors)) $captcha_null = $errors['captcha_null'];
				if (key_exists("captcha_incorrect", $errors)) $captcha_incorrect = $errors['captcha_incorrect'];
			}
		?>
	<form action="<?= $this -> baseUrl ?>/<?= $this->contextPath ?>" method="post">
		<p class="reg_sep"><span style="background-color: white;">Thông tin tài khoản</span></p>
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>	
				<td width="30%" align="right">
					<b>Số điện thoại di động (*):</b> 
				</td>
				<td width="70%" align="left" style="font-size: 8pt;">
					<input class="input" maxlength="12" type="text" name="usr_mobile" value="<?php echo $account->usr_mobile; ?>" style="width: 250px;"/>
					<?php if (isset($mobile_null)){ ?>
						<span style="color:red;"><?php echo $mobile_null; ?></span>					
					<?php }else if (isset($mobile_exist)){ ?>
						<span style="color:red;"><?php echo $mobile_exist; ?></span>					
					<?php }else if (isset($mobile_incorrect)){ ?>
						<span style="color:red;"><?php echo $mobile_incorrect; ?></span>
					<?php } else { ?>
						(Ví dụ: 0915123456)
					<?php } ?>
				</td>
			</tr>
			<tr>
				<td align="right">
					<b>Mật khẩu (*):</b>
				</td>
				<td align="left" style="font-size: 8pt;">
					<input class="input" maxlength="32" type="password" name="usr_password" value="" style="width: 250px;"/>
					<?php if (isset($password_null)){ ?>
						<span style="color:red;"><?php echo $password_null; ?></span>					
					<?php } else if (isset($password_incorrect)){ ?>
						<span style="color:red;"><?php echo $password_incorrect; ?></span>
					<?php } else { ?>
						(Mật khẩu phải có ít nhất 6 kí tự)
					<?php } ?>
					
				</td>
			</tr>
			<tr>
				<td align="right">
					<b>Gõ lại mật khẩu (*):</b>
				</td>
				<td align="left" style="font-size: 8pt;">
					<input class="input" maxlength="32" type="password" name="usr_password2" value="" style="width: 250px;"/>
					<?php if (isset($password2_incorrect)){ ?>
						<span style="color:red; font-weight:bold;"><?php echo $password2_incorrect; ?></span>
					<?php } ?>
				</td>
			</tr>
		</table>
		<p class="reg_sep"><span style="background-color: white;">Thông tin cá nhân</span></p>			
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td width="30%" align="right">
					<b>Nơi bạn đang sống (*):</b>
				</td>
				<td align="left" style="font-size: 8pt;">
					<select style="width: 150px;" name="usr_city">						
						<?php
							foreach ($cities as $key => $value) {
								if ($account->usr_city == $key){
									echo "<option value='$key' selected>$value</option>";
								} else {
									echo "<option value='$key'>$value</option>";
								}
							}
						?>
					</select>
					<?php if (isset($city_null)){ ?>
						<span style="color:red;"><?php echo $city_null; ?></span>
					<?php } ?>
				</td>
			</tr>
			<tr>
				<td width="30%"  align="right">
					<b>Họ tên đầy đủ (*):</b>
				</td>
				<td align="left" style="font-size: 8pt;">
					<input class="input" maxlength="50" type="text" name="usr_fullname" value="<?php echo $account->usr_fullname; ?>" style="width: 250px;"/>
					<?php if (isset($fullname_null)){ ?>
						<span style="color:red;"><?php echo $fullname_null; ?></span>
					<?php } ?>
				</td>
			</tr>
			<tr>
				<td align="right">
					<b>Ngày sinh (*):</b>
				</td>
				<td align="left" style="font-size: 8pt;">
					<table cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td style="padding-right:5px;">
								<select name="day">
									<option value="0"/>Ngày
									<?
									for ($i=1; $i<=31; $i++){
									?>
										<option value="<?php echo $i;?>" <?php if($day==$i): echo "selected='selected'"; endif;?>><?php echo $i; ?></option>
									<?php 
									}
									?>
								</select>
							</td>
							<td style="padding-right:5px;">
								<select name="month">
									<option value="0"/>Tháng
									<?
									for ($i=1; $i<=12; $i++){
									?>
										<option value="<?php echo $i;?>" <?php if($month==$i): echo "selected='selected'"; endif;?>><?php echo $i; ?></option>
									<?php 
									}
									?>
								</select>
							</td>
							<td>
								<select name="year">
									<option value="0"/>Năm
									<?
									$year = date('Y');
									for ($i=$year-10; $i>=$year-70; $i--){
									?>
										<option value="<?php echo $i;?>" <?php if($y==$i): echo "selected='selected'"; endif;?>><?php echo $i; ?></option>
									<?php 
									}
									?>
								</select>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td align="right">
					<b>Địa chỉ email (*):</b>
				</td>
				<td align="left" style="font-size: 8pt;">
					<input class="input" maxlength="100" type="text" name="usr_email" value="<?php echo $account->usr_email; ?>" style="width: 250px;"/>
					<?php if (isset($email_null)){ ?>
						<span style="color:red;"><?php echo $email_null; ?></span>
					<?php
						} else if (isset($email_incorrect)){
					?>
						<span style="color:red;"><?php echo $email_incorrect; ?></span>
					<?php } else { ?>
						(ví dụ: email@gmail.com)
					<?php } ?>
				</td>
			</tr>
			<tr>
				<td align="right"/>
				<td valign="middle">
					<img src="<?= $this -> baseUrl ?>/<?= $this->contextPath ?>/captcha?sid=<?php echo md5(uniqid(time())); ?>" id="captcha_image" align="absmiddle"/>
					<a href="javascript:void(0);" onclick="document.getElementById('captcha_image').src = '<?= $this -> baseUrl ?>/<?= $this->contextPath ?>/captcha?sid=' + Math.random(); return false">
						<img border="0" src="<?= $this -> baseUrl ?>/public/images/frontend/refresh.gif" alt="Đổi ảnh khác" title="Đổi ảnh khác"/>
					</a>					
				</td>
			</tr>			
			<tr>
				<td align="right">
					<b>Nhập mã kiểm tra (*):</b>
				</td>
				<td align="left" style="font-size: 8pt;">					
					<input class="input" maxlength="100" style="width: 150px" type="text" name="captcha"/>
					<?php if (isset($captcha_incorrect)){ ?>
						<span style="color:red;"><?php echo $captcha_incorrect; ?></span>
					<?php } ?>
					<?php if (isset($captcha_null)){ ?>
						<span style="color:red;"><?php echo $captcha_null; ?></span>
					<?php } ?>
				</td>
			</tr>
			<tr>
				<td/>
				<td align="left" style="padding:15px 0 15px 0;">
					<input type="image" src="<?= $this->baseUrl ?>/public/images/frontend/create_account_button.jpg" border="0" />
				</td>
			</tr>
		</table>
	</form>	
</div>
<?php echo $this->render('footer.phtml');?> 